<?php get_backend_header(array(
	'jquery/validate/jquery.validate.js',
        'jquery/validate/additional-methods.js',
	'group.js',
)); ?>

<?php if ( ! $is_joined ) { ?>

<div id ="join_group_div" class ="hidden">
    <h3 class="title">Enter Password</h3>

    <form id="join_group_form" name="join_group_form" class="form" style ="width: 450px" >
            <input type="hidden" id="group_id" name="group_id" value="<?php echo $group['group_id']; ?>" />
            <div class="unit">
                <div class="line">
                        <label for="" class="bold">Class:</label>
                        <div class="field" style="height:auto">
                          <?php echo $group['group_name']; ?>
                        </div>
                </div>
                <div class="line">
                        <label for="" class="bold">Password:</label>
                        <div class="field" style="height:auto">
                          <input type ="password" name ="password" id ="password" />
                        </div>
                </div>

                <div id="err" class="ui-state-error ui-corner-all line" style="margin-top: 10px;display:none; padding: 6px;">
                    <span class="icon icon-info"></span>
                    <span class="msg"></span>
                </div>
            </div>
    </form>
</div>

<script>
    join_group_dialog();
    $("#password").keydown(function(event){
        buttons = $( "#join_group_div" ).next('.ui-dialog-buttonpane').find(':button');
        if(event.keyCode == 13){
            $(buttons[1]).focus();
        }
    });
</script>

<?php } else { ?>

<h2 class="title">Class  - <?php echo ($group['group_name']) ?></h2>

<?php get_group_sidebar($group['group_id']); ?>

<div id ="content" >
    <h3>Welcome!</h3>
</div>

<script type="text/javascript">
        groupRules();


	$('#cancel').button({
		icons: {primary: 'ui-icon-arrowreturn-1-w'}
	});	
	
	$('#save').button({
		icons: {primary: 'ui-icon-disk'}
	}).click(function(e) {
		$(this).removeClass('ui-state-focus');
		$('#group_form').submit();
		e.preventDefault();
	});	

</script>
<?php }
    get_backend_footer();
